package cn.study.vue_project_xxx.controller;


import cn.study.vue_project_xxx.common.result.ResultSet;
import cn.study.vue_project_xxx.entity.dto.TAdminRoleDTO;
import cn.study.vue_project_xxx.entity.po.TAdminRole;
import cn.study.vue_project_xxx.util.PageParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;


import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.study.vue_project_xxx.service.TAdminRoleService;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (TAdminRole)表控制层
 *
 * @author makejava
 * @since 2023-04-25 09:53:59
 */
@Api(tags = "接口")
@RestController
@RequestMapping("/api/v1/tAdminRole")
@Slf4j
public class TAdminRoleController {
    /**
     * Service层对象
     */
    @Autowired
    private TAdminRoleService tAdminRoleService;


    /*
    * 增加管理员的角色
    * */
    @PostMapping("/addAdminRole")
    public ResultSet<Boolean> addAdminRole(@RequestBody TAdminRole adminRole) {
        return ResultSet.success(tAdminRoleService.addAdminRole(adminRole));
    }

    /*
     * 修改管理员的角色
     * */
    @PostMapping("/updateAdminRole")
    public ResultSet<Boolean> updateAdminRole(@RequestBody TAdminRole adminRole) {
        return ResultSet.success(tAdminRoleService.updateAdminRole(adminRole));
    }

    /*
     * 批量删除管理员的角色
     * */
    @PostMapping("/deleteAdminRole")
    public ResultSet<Boolean> deleteAdminRole(List<Integer> roleId) {
        return ResultSet.success(tAdminRoleService.deleteAdminRole(roleId));
    }

    /*
     * 分页查询管理员的角色
     * */
    @PostMapping("/selectAdminRole")
    public ResultSet<Page<TAdminRole>> selectAdminRole(@RequestParam Integer adminId, Integer currentPage, Integer pageSize) {
        Page<TAdminRole> pageParam = new Page<>(currentPage,pageSize);
        return ResultSet.success(tAdminRoleService.selectAdminRole(adminId,pageParam));
    }
}

